<template>
    <input type="text" v-model="username" />
    {{ username }}

    <button @click="clickMe">绑定事件</button>


    {{ count }}

  
    <div ref="text">ref用法</div>
</template>

<script>
    export default {
        data(){
            return {
                username:'',
            }
        },
        methods: {
            ClickMe()
            {
                alert('触发事件')
            }
        },
        computed:{
            count()
            {
                var num = 5.56789
                var res = num.toFixed(2)
                return res 
            }
        },
        watch:{
            username(newval,oldval)
            {
                console.log(`旧的值：${oldval}`)
                console.log(`新的值：${newval}`)
            }
        },
        mounted()
        {
            console.log(this.$refs.test)
        },
    }
</script>